// pages/community/index.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        List: [
            {typeName: "全部", typeId: "1"},
            {typeName: "选购指南", typeId: "2"},
            {typeName: "菜谱分享", typeId: "3"}
        ],
        checkedListInfo: [
            {
                id: 1,
                imageUrl: "https://st-cn.meishij.net/r/178/85/5833928/s5833928_153025818936955.jpg",
                title: "苹果原来还能这么吃！",
                author: "惠农汇官方推送",
                like: 156
            }, {
                id: 2,
                imageUrl: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F014e3c5df72fe3a8012097b3a37a9a.jpg%403000w_1l_0o_100sh.jpg&refer=http%3A%2F%2Fimg.zcool.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639378027&t=c3e4a6314011997ec47943a6099db5d9",
                title: "婴幼儿食谱",
                author: "育儿官方推送",
                like: 329
            }
        ]
    },


    // 切换分类
    switchTabList(e) {
        console.log(e)
        const id = parseInt(e.currentTarget.id)
        const type = e.currentTarget.dataset["listtitle"]
        var tabListInfo = []
        if (type === "全部") {
            tabListInfo = this.data.goodsList
        } else {
            this.data.goodsList.forEach(element => {
                if (element.typeId === parseInt(id)) {
                    tabListInfo.push(element)
                }
            });
        }
        this.setData({
            checkedListNum: parseInt(id),
            checkedListInfo: tabListInfo
        })
    },


    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        wx.request({
            url: 'https://mbp.jyccloud.cn/mbp/getArticleType',
            success: (res) => {

            }
        })
        wx.request({
            url: 'https://mbp.jyccloud.cn/mbp/getArticleList',
            success: (res) => {

            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})